package com.ch.home.testMapper;

import com.ch.home.bean.Commodity;
import com.ch.home.bean.CommodityRecord;
import com.ch.home.mapper.mallMapper.MallMapper;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import java.util.Date;

/**
 * Created by CHEN on 2019/8/25.
 */
@RunWith(SpringRunner.class)
@SpringBootTest
public class testMallMapper {

    @Autowired
    MallMapper mallMapper;


//    LinkedList<Commodity> getInfo(Commodity commodity);

    @Test
    public void testGetInfo() {

        Commodity commodity = new Commodity( );
//        commodity.setCommodityName("hel");
        commodity.setCommodityDescription("月");
        System.out.println(mallMapper.getCommodityInfo(commodity));

    }

    //    int addCommodity(Commodity commodity);
    @Test
    public void testAddCommodity() {
        Commodity commodity = new Commodity(null, "腾讯会员", 20000, 6, "腾讯会员月卡", 999, "http://www.aliyouth.cn/repository/Image/CodeResource.png", new Date( ), 1);

        System.out.println(mallMapper.addCommodity(commodity));
        System.out.println("---------------------------------");
        System.out.println(commodity);
    }

    //    int updateCommodity(Commodity commodity);
    @Test
    public void testUpdateCommodity() {
        Commodity commodity = new Commodity(1, "Hello月卡", 10000, 3, "Hello单车月卡", 999, "http://www.aliyouth.cn/repository/Image/CodeResource.png", new Date( ), 1);

        System.out.println(mallMapper.updateCommodity(commodity));
    }

    //    int insertInfo(CommodityRecord commodityRecord);
    @Test
    public void testInsertInfo() {
        CommodityRecord commodityRecord = new CommodityRecord(null, 1, 1,new Date(), 10000, 5);
        System.out.println(mallMapper.insertInfo(commodityRecord));

    }
//    LinkedList<CommodityRecord> getRecordInfo(CommodityRecord commodityRecord);

    @Test
    public void testGetRecordInfo(){
        CommodityRecord commodityRecord= new CommodityRecord();
        System.out.println(mallMapper.getRecordInfo(commodityRecord) );
    }

}

